package com.zzt.community.controller;

import com.zzt.community.dao.CcbDemoMapper;
import com.zzt.community.entity.CcbDemo;
import com.zzt.community.service.CcbDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Classname: CcbDemoController
 * Package: com.zzt.community.controller
 * Description:
 *
 * @Author:zzt
 * @Create: 2024/3/5-22:38
 * Version:
 */
@Controller
@RequestMapping("/ccbDemo")
public class CcbDemoController {
//注入service层，提供查询方法
    @Autowired
    private  CcbDemoService ccbDemoService;

//浏览器访问路径为 http://localhost:8080/community/ccbDemo/hello
// Model是springMVC中用于controller层与view层之间传递数据的工具，ModelMap可以实现相同功能
    @RequestMapping(path = "hello", method = RequestMethod.GET)
    public String getText(Model model){
        CcbDemo ccbDemo= ccbDemoService.findCcbDemoById(2);
        model.addAttribute("text",ccbDemo.getText());
        return "/demo/ccbDemo";
    }
}
